package org.example.util;

import java.io.*;
import java.util.Objects;
import java.util.Properties;

/**
 * @author TonySong
 * @date 2025/8/4 0004
 * @time 11:08
 */
public class PropertiesUtil {
   private static final Properties properties = new Properties();
    public static boolean checkUser(File file,String name,String pwd){
        Boolean flag=false;
        if(Objects.nonNull(file)){
            Reader reader = null;
            try {
                reader = new FileReader(file);
                properties.load(reader);
                String username = properties.getProperty("username");
                String password = properties.getProperty("password");
                if(username.equals(name) && password.equals(pwd)){
                    System.out.println("登录成功！");
                    flag=true;
                }else{
                    System.out.println("登录失败！");
                    flag=false;
                }
                reader.close();
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }else{
            System.out.println("文件为空：请查看文件名或路径是否正确！");
        }
        return flag;
    }
}
